
package com.jf.cloud.auth.feign;

import com.jf.cloud.api.auth.feign.PasswordFeignClient;
import com.jf.cloud.auth.manager.PasswordManager;
import com.jf.cloud.common.response.ServerResponseEntity;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 菠萝凤梨
 * @date 2022/1/20 15:07
 */
@RestController
@Hidden
public class PasswordFeignController implements PasswordFeignClient {

    @Autowired
    private PasswordManager passwordManager;

    @Override
    public ServerResponseEntity<String> getDecryptPassword(String password) {
        ServerResponseEntity<String> decryptPasswordEntity = passwordManager.decryptPassword(password);
        if (!decryptPasswordEntity.isSuccess()) {
            return ServerResponseEntity.transform(decryptPasswordEntity);
        }
        return ServerResponseEntity.success(decryptPasswordEntity.getData());
    }
}
